package com.cykj.service.Impl;

import com.cykj.dto.ResponseDto;
import com.cykj.mapper.ConsultantMapper;
import com.cykj.pojo.PsConsultant;
import com.cykj.pojo.PsType;
import com.cykj.service.ConsultantService;
import com.cykj.vo.BookingVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @BelongsProject: Psychology
 * @BelongsPackage: com.cykj.service.Impl
 * @Author: 小林
 * @CreateTime: 2025-02-10 15:25
 * @Description: TODO
 * @Version: 1.0
 */
@Service
public class ConsultantServiceImpl implements ConsultantService {
    @Autowired
    private ConsultantMapper consultantMapper;

    /**
     * //后台预约列表显示（咨询记录表、用户表、领域表）
     *
     * @param vo
     * @return
     */
    @Override
    public ResponseDto getConsultantAndUserAndType(BookingVo vo) {
        PageHelper.startPage(vo.getPageNum(), vo.getPageSize());
        List<PsConsultant> consultantAndUserAndType = consultantMapper.getConsultantAndUserAndType(vo);
        PageInfo<PsConsultant> pageInfo = new PageInfo<>(consultantAndUserAndType);
        return pageInfo != null ? ResponseDto.success(pageInfo) : ResponseDto.error("查询有误！");
    }

    /**
     * 修改评价
     * @param vo
     * @return
     */
    @Override
    public ResponseDto updateAppointmentReply(BookingVo vo) {
        int i = consultantMapper.updateAppointmentReply(vo);
        if (i > 0) {
            return ResponseDto.success("修改成功！");
        }
        return ResponseDto.error("修改有误！");
    }

    /**
     * 修改状态
     * @param vo
     * @return
     */
    @Override
    public ResponseDto updateAppointmentStatus2(BookingVo vo) {
        int i = consultantMapper.updateAppointmentStatus2(vo);
        if (i > 0) {
            return ResponseDto.success("修改成功！");
        }
        return ResponseDto.error("修改有误！");
    }
    /**
     * 修改状态
     * @param vo
     * @return
     */
    @Override
    public ResponseDto updateAppointmentStatus3(BookingVo vo) {
        int i = consultantMapper.updateAppointmentStatus3(vo);
        if (i > 0) {
            return ResponseDto.success("修改成功！");
        }
        return ResponseDto.error("修改有误！");
    }
    /**
     * 修改状态
     * @param vo
     * @return
     */
    @Override
    public ResponseDto updateAppointmentStatus4(BookingVo vo) {
        int i = consultantMapper.updateAppointmentStatus4(vo);
        if (i > 0) {
            return ResponseDto.success("修改成功！");
        }
        return ResponseDto.error("修改有误！");
    }
    /**
     * 修改状态
     * @param vo
     * @return
     */
    @Override
    public ResponseDto updateAppointmentStatus5(BookingVo vo) {
        int i = consultantMapper.updateAppointmentStatus5(vo);
        if (i > 0) {
            return ResponseDto.success("修改成功！");
        }
        return ResponseDto.error("修改有误！");
    }

    /**
     * 获取全部领域
     * @return
     */
    @Override
    public ResponseDto getTypeAll() {
        List<PsType> geTypeAll = consultantMapper.getTypeAll();
        if (geTypeAll != null) {
            return ResponseDto.success(geTypeAll);
        }
        return ResponseDto.error("查询错误！");
    }

    /**
     * 根据id获取对应的领域
     * @param typeId
     * @return
     */
    @Override
    public ResponseDto getPsConsultantAndPsType(Integer typeId) {
        List<PsConsultant> getPsConsultantAndPsType = consultantMapper.getPsConsultantAndPsType(typeId);
        if (getPsConsultantAndPsType != null) {
            return ResponseDto.success(getPsConsultantAndPsType);
        }
        return ResponseDto.error("查询错误！");
    }

    /**
     * 根据id获取咨询师设置的时间段
     * @param adminId
     * @return
     */
    @Override
    public ResponseDto getConsultantTime(Integer adminId) {
        List<PsConsultant> getTime = consultantMapper.getConsultantTime(adminId);
        if (getTime != null) {
            return ResponseDto.success(getTime);
        }
        return ResponseDto.error("查询错误！");
    }

    /**
     * 根据id获取评价内容
     * @param adminId
     * @return
     */
    @Override
    public ResponseDto getPsConsultantText(Integer adminId) {
        List<PsConsultant> getText = consultantMapper.getPsConsultantText(adminId);
        if (getText != null) {
            return ResponseDto.success(getText.get(0));
        }
        return ResponseDto.error("查询错误！");
    }
}

